﻿using AutoMapper;
using DFGK_WMS.Context;
using DFGK_WMS.IRepository;
using DFGK_WMS.Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace DFGK_WMS.Repository
{
    /// <summary>
    /// 输送线设备信息
    /// </summary>
    public class TPipeLineRepository: BaseRepository<TPipeLine>, ITPipeLineRepository
    {
        public TPipeLineRepository(DFGK_DB context, IMapper mapper) : base(context, mapper)
        {
        }
        /// <summary>
        /// 添加输送线设备信息
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public bool AddPipeLine(TPipeLine line)
        {
            Context.TPipeLines.Add(line);
            return Context.SaveChanges() > 0;
        }
        /// <summary>
        /// 输送线设备查询
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public TPipeLine GetPipeLine(Expression<Func<TPipeLine, bool>> where)
        {
            return Context.TPipeLines.Where(where).FirstOrDefault();
        }
        /// <summary>
        /// 输送线设备修改
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public bool UpdatePipeLine(TPipeLine line)
        {
            Context.TPipeLines.Update(line);
            return Context.SaveChanges() > 0;
        }
    }
}
